/**
 * 全屏广告插件
 * @param  
 * @return 
 * 调用方法
 * $.fullPopBox({
 * 	imgSrc:'',//图片地址
 * 	href:'',//图片链接
 * });
 */
$.extend({
	fullPopBox:function(options){
		options = $.extend({
			imgSrc:'',
			href:'',
			showtime:3,
		},options);
		if(options.imgSrc){
			var img = new Image();
			img.src = options.imgSrc;
			img.onload=function(){
				var iheight = img.height; 
				var iwidth = img.width;
				iwidth = iwidth>500?500:iwidth;
				iheight = iheight>350?350:iheight;
				$("body").append("<div class='fullBack'><div class='fullPopBox'><a href='"+options.href+"'><img src='"+options.imgSrc+"' width='"+iwidth+"' /></a><span>关闭 X</span></div></div>");
				width = $(window).width();
				height = $(window).height();
				$(".fullBack").css({
					"position":"absolute",
					//"z-index":999,
					"left":0,
					"top":0,
					"width":"100%",
					"height":"100%",
					"background":"rgba(255,250,240,0.5)",
				});
				$(".fullPopBox").css({
					"position":"fixed",
					"top":(height-iheight)/2+"px",
					"left":(width-iwidth)/2+"px",
					//"z-index":9999,
					"width":iwidth+"px",
					"height":iheight+"px",
				});
				$(".fullPopBox span").css({
					"position":"absolute",
					"top":"2px",
					"right":"5px",
					//"z-index":10000,
					"font-size":"12px",
					"cursor":"pointer",
				});
				$(".fullPopBox span").click(function(){
					$(".fullBack").fadeOut(600);
					$(".fullPopBox").fadeOut(600);
				});
			};
			var showtime = parseInt(options.showtime);
			setTimeout(function(){
				$(".fullBack").fadeOut(600);
				$('.fullPopBox').fadeOut(600);
			},showtime*1000); //默认3秒关闭
		}
	}
});